﻿/*using Kingdee.BOS.JSON;
using Kingdee.BOS.ServiceFacade.KDServiceFx;
using Kingdee.BOS.ServiceHelper;
using Kingdee.BOS.WebApi.ServicesStub;*/
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;

namespace KingDee.api.ServicesStub
{
    /*public class CustomBusinessService : AbstractWebApiBusinessService
    {
        public CustomBusinessService(KDServiceContext context)
            : base(context)
        {
        }
        public RETURNROOT ExecuteService(ROOT parameter)
        {
            RETURNROOT _RETURNROOT = new RETURNROOT();
            List<string> _Exceptionlist = new List<string>();
            if (parameter.FormId == "Intervalinventory")
            {
                try
                {
                    string sql = GETsqlstr();
                    sql += (string.Format("\r\n exec('select {4} {0} from #LS {1} {2} {3}')",
                        (parameter.FieldKeys == null || parameter.FieldKeys.Trim() == "" ? " * " : parameter.FieldKeys).Replace("'", "''"),
                        (parameter.FilterString == null || parameter.FilterString.Trim() == "" ? " " : " where " + parameter.FilterString).Replace("'", "''"),
                        (parameter.GroupString == null || parameter.GroupString.Trim() == "" ? " " : " group by " + parameter.GroupString).Replace("'", "''"),
                        (parameter.OrderString == null || parameter.OrderString.Trim() == "" ? " " : " order by " + parameter.OrderString).Replace("'", "''"),
                        (parameter.TopRowCount == 0 ? "" : "top " + parameter.TopRowCount.ToString()).Replace("'", "''")));
                    sql += "\r\n DROP TABLE #LS";
                    DataSet ds = DBServiceHelper.ExecuteDataSet(this.KDContext.Session.AppContext, sql);
                    if (ds.Tables.Count > 0)
                    {
                        _RETURNROOT.DataTable = ds.Tables[0];
                        _RETURNROOT.Success = true;
                    }
                }
                catch (Exception e)
                {
                    _RETURNROOT.Success = false;
                    _Exceptionlist.Add(e.ToString());
                }
            }
            else
            {
                _RETURNROOT.Success = false;
                _Exceptionlist.Add("FormId有误！");
            }
            _RETURNROOT.Exception = _Exceptionlist;
            return _RETURNROOT;
        }*/

    //    public string GETsqlstr()
    //    {
    //        string sql = "/*dialect*/ ";
    //        sql += "\r\n select FAPPROVEDATE,FORG.FNUMBER FStockOrgID,FORG.FNAME FStockOrgNAME,";
    //        sql += "\r\n FMAT.FNUMBER FMATERIALID,FMAT.FNAME FMATERIALNAME,";
    //        sql += "\r\n FMAT.FNUMBER FSTOCKID,FMAT.FNAME FSTOCKNAME,";
    //        sql += "\r\n FSTOCKLOCID,FLOT,";
    //        sql += "\r\n FBASEUNI.FNUMBER FBASEUNITID,FBASEUNI.FNAME FBASEUNITNAME,FBASEQTY,";
    //        sql += "\r\n FUNI.FNUMBER FSTOCKUNITID,FUNI.FNAME FSTOCKUNITNAME,FQTY";
    //        sql += "\r\n into #LS";
    //        sql += "\r\n from";
    //        sql += "\r\n (";
    //        sql += "\r\n 	--入库";
    //        sql += "\r\n 	select i.FAPPROVEDATE,i.FStockOrgID,j.FMATERIALID,j.FSTOCKID,j.FSTOCKLOCID,j.FLOT,";
    //        sql += "\r\n 	j.FBASEUNITID,isnull(j.FBASEQTY,0) FBASEQTY,j.FUNITID,isnull(j.FQTY,0) FQTY";
    //        sql += "\r\n 	from T_STK_INVINIT i with(nolock) --初始库存";
    //        sql += "\r\n 	inner join T_STK_INVINITDETAIL j with(nolock) on i.FID=j.FID";
    //        sql += "\r\n 	WHERE FDOCUMENTSTATUS='C'";

    //        sql += "\r\n 	union all";
    //        sql += "\r\n 	select i.FAPPROVEDATE,i.FSTOCKORGID,j.FMATERIALID,j.FSTOCKID,j.FSTOCKLOCID,j.FLOT,";
    //        sql += "\r\n 	j.FBASEUNITID,isnull(j.FBASEUNITQTY,0),j.FUNITID,isnull(j.FREALQTY,0) ";
    //        sql += "\r\n 	from t_STK_InStock i with(nolock) --采购入库单";
    //        sql += "\r\n 	inner join T_STK_INSTOCKENTRY j with(nolock) on i.FID=j.FID";
    //        sql += "\r\n 	WHERE FDOCUMENTSTATUS='C'";

    //        sql += "\r\n 	union all";
    //        sql += "\r\n 	select i.FAPPROVEDATE,i.FSTOCKORGID,j.FMATERIALID,j.FSTOCKID,j.FSTOCKLOCID,j.FLOT,";
    //        sql += "\r\n 	j.FBASEUNITID,isnull(j.FBASEREALQTY,0),j.FUNITID,isnull(j.FREALQTY,0)";
    //        sql += "\r\n 	from T_PRD_INSTOCK i with(nolock) --生产入库单";
    //        sql += "\r\n 	inner join T_PRD_INSTOCKENTRY j with(nolock) on i.FID=j.FID";
    //        sql += "\r\n 	WHERE FDOCUMENTSTATUS='C'";

    //        sql += "\r\n 	union all";
    //        sql += "\r\n 	select i.FAPPROVEDATE,i.FSTOCKORGID,j.FMATERIALID,j.FSTOCKID,j.FSTOCKLOCID,j.FLOT,";
    //        sql += "\r\n 	j.FBASEUNITID,isnull(j.FBASEREALQTY,0),j.FUNITID,isnull(j.FREALQTY,0)";
    //        sql += "\r\n 	from T_SP_INSTOCK i with(nolock) --简单生产入库单";
    //        sql += "\r\n 	inner join T_SP_INSTOCKENTRY j with(nolock) on i.FID=j.FID";
    //        sql += "\r\n 	WHERE FDOCUMENTSTATUS='C'";

    //        sql += "\r\n 	union all";
    //        sql += "\r\n 	select i.FAPPROVEDATE,i.FSTOCKORGID,j.FMATERIALID,j.FSTOCKID,j.FSTOCKLOCID,j.FLOT,";
    //        sql += "\r\n 	j.FBASEUNITID,isnull(j.FBASEQTY,0),j.FUNITID,isnull(j.FQTY,0)";
    //        sql += "\r\n 	from T_PRD_RETURNMTRL i with(nolock) --生产退料单";
    //        sql += "\r\n 	inner join T_PRD_RETURNMTRLENTRY j with(nolock) on i.FID=j.FID";
    //        sql += "\r\n 	WHERE FDOCUMENTSTATUS='C'";

    //        sql += "\r\n 	union all";
    //        sql += "\r\n 	select i.FAPPROVEDATE,i.FSTOCKORGID,j.FMATERIALID,j.FSTOCKID,j.FSTOCKLOCID,j.FLOT,";
    //        sql += "\r\n 	j.FBASEUNITID,isnull(j.FBASEQTY,0),j.FUNITID,isnull(j.FQTY,0)";
    //        sql += "\r\n 	from T_SP_RETURNMTRL i with(nolock) --简单生产退料单";
    //        sql += "\r\n 	inner join T_SP_RETURNMTRLENTRY j with(nolock) on i.FID=j.FID";
    //        sql += "\r\n 	WHERE FDOCUMENTSTATUS='C'";

    //        sql += "\r\n 	union all";
    //        sql += "\r\n 	select i.FAPPROVEDATE,i.FSTOCKORGID,j.FMATERIALID,j.FSTOCKID,j.FSTOCKLOCID,j.FLOT,";
    //        sql += "\r\n 	j.FBASEUNITID,isnull(j.FBASEQTY,0),j.FUNITID,isnull(j.FQTY,0)";
    //        sql += "\r\n 	from T_SUB_RETURNMTRL i with(nolock) --委外退料单";
    //        sql += "\r\n 	inner join T_SUB_RETURNMTRLENTRY j with(nolock) on i.FID=j.FID";
    //        sql += "\r\n 	WHERE FDOCUMENTSTATUS='C'";

    //        sql += "\r\n 	union all";
    //        sql += "\r\n 	select i.FAPPROVEDATE,i.FSTOCKORGID,j.FMATERIALID,j.FSTOCKID,j.FSTOCKLOCID,j.FLOT,";
    //        sql += "\r\n 	j.FBASEUNITID,isnull(j.FBASEUNITQTY,0),j.FUNITID,isnull(j.FREALQTY,0)";
    //        sql += "\r\n 	from T_SAL_RETURNSTOCK i with(nolock) --销售退货单";
    //        sql += "\r\n 	inner join T_SAL_RETURNSTOCKENTRY j with(nolock) on i.FID=j.FID";
    //        sql += "\r\n 	WHERE FDOCUMENTSTATUS='C' and i.FBILLNO not in ('SR-2003000289')";
            
    //        sql += "\r\n 	union all";
    //        sql += "\r\n 	select i.FAPPROVEDATE,i.FSTOCKORGID,j.FMATERIALID,j.FSTOCKID,j.FSTOCKLOCID,j.FLOT,";
    //        sql += "\r\n 	j.FBASEUNITID,isnull(j.FBASEQTY,0),j.FUNITID,isnull(j.FQTY,0)";
    //        sql += "\r\n 	from T_STK_OEMINSTOCK i with(nolock) --受托加工材料入库单";
    //        sql += "\r\n 	inner join T_STK_OEMINSTOCKENTRY j with(nolock) on i.FID=j.FID";
    //        sql += "\r\n 	WHERE FDOCUMENTSTATUS='C'";

    //        sql += "\r\n 	union all";
    //        sql += "\r\n 	select i.FAPPROVEDATE,i.FSTOCKORGID,j.FMATERIALID,j.FSTOCKID,j.FSTOCKLOCID,j.FLOT,";
    //        sql += "\r\n 	j.FBASEUNITID,isnull(j.FBASEGAINQTY,0),j.FUNITID,isnull(j.FGAINQTY,0)";
    //        sql += "\r\n 	from T_STK_STKCOUNTGAIN i with(nolock) --盘盈单";
    //        sql += "\r\n 	inner join T_STK_STKCOUNTGAINENTRY j with(nolock) on i.FID=j.FID";
    //        sql += "\r\n 	WHERE FDOCUMENTSTATUS='C'";

    //        sql += "\r\n 	union all";
    //        sql += "\r\n 	select i.FAPPROVEDATE,i.FSTOCKORGID,j.FMATERIALID,j.FSTOCKID,j.FSTOCKLOCID,j.FLOT,";
    //        sql += "\r\n 	j.FBASEUNITID,isnull(j.FBASEQTY,0),j.FUNITID,isnull(j.FQTY,0)";
    //        sql += "\r\n 	from T_STK_MISCELLANEOUS i with(nolock) --其他入库单";
    //        sql += "\r\n 	inner join T_STK_MISCELLANEOUSENTRY j with(nolock) on i.FID=j.FID";
    //        sql += "\r\n 	WHERE FDOCUMENTSTATUS='C'";

    //        sql += "\r\n 	union all";
    //        sql += "\r\n 	select i.FAPPROVEDATE,i.FSTOCKORGID,j.FMATERIALID,j.FSTOCKID,j.FSTOCKLOCID,j.FLOT,";
    //        sql += "\r\n 	j.FBASEUNITID,isnull(j.FBASEREALQTY,0),j.FUNITID,isnull(j.FREALQTY,0)";
    //        sql += "\r\n 	from T_REM_INSTOCK i with(nolock) --生产线产品入库单";
    //        sql += "\r\n 	inner join T_REM_INSTOCKENTRY j with(nolock) on i.FID=j.FID";
    //        sql += "\r\n 	WHERE FDOCUMENTSTATUS='C'";

    //        sql += "\r\n 	union all";
    //        sql += "\r\n 	select i.FAPPROVEDATE,i.FSTOCKORGID,j.FMATERIALID,j.FSTOCKID,j.FSTOCKLOCID,j.FLOT,";
    //        sql += "\r\n 	j.FBASEUNITID,isnull(j.FBASEQTY,0),j.FUNITID,isnull(j.FQTY,0)";
    //        sql += "\r\n 	from T_REM_RETURNMTRL i with(nolock) --生产线退料单";
    //        sql += "\r\n 	inner join T_REM_RETURNMTRLENTRY j with(nolock) on i.FID=j.FID";
    //        sql += "\r\n 	WHERE FDOCUMENTSTATUS='C'";

    //        sql += "\r\n 	------出库";
    //        sql += "\r\n 	union all";
    //        sql += "\r\n 	select i.FAPPROVEDATE,i.FSTOCKORGID,j.FMATERIALID,j.FSTOCKID,j.FSTOCKLOCID,j.FLOT,";
    //        sql += "\r\n 	j.FBASEUNITID,-1*isnull(j.FBASEUNITQTY,0),j.FUNITID,-1*isnull(j.FREALQTY,0)";
    //        sql += "\r\n 	from T_SAL_OUTSTOCK i with(nolock) --销售出库单";
    //        sql += "\r\n 	inner join T_SAL_OUTSTOCKENTRY j with(nolock) on i.FID=j.FID";
    //        sql += "\r\n 	WHERE FDOCUMENTSTATUS='C' ";

    //        sql += "\r\n 	union all";
    //        sql += "\r\n 	select i.FAPPROVEDATE,i.FSTOCKORGID,j.FMATERIALID,j.FSTOCKID,j.FSTOCKLOCID,j.FLOT,";
    //        sql += "\r\n 	j.FBASEUNITID,-1*isnull(j.FBASEACTUALQTY,0),j.FUNITID,-1*isnull(j.FACTUALQTY,0)";
    //        sql += "\r\n 	from T_PRD_PICKMTRL i with(nolock) --生产领料单";
    //        sql += "\r\n 	inner join T_PRD_PICKMTRLDATA j with(nolock) on i.FID=j.FID";
    //        sql += "\r\n 	WHERE FDOCUMENTSTATUS='C'";

    //        sql += "\r\n 	union all";
    //        sql += "\r\n 	select i.FAPPROVEDATE,i.FSTOCKORGID,j.FMATERIALID,j.FSTOCKID,j.FSTOCKLOCID,j.FLOT,";
    //        sql += "\r\n 	j.FBASEUNITID,-1*isnull(j.FBASEACTUALQTY,0),j.FUNITID,-1*isnull(j.FACTUALQTY,0)";
    //        sql += "\r\n 	from T_SP_PICKMTRL i with(nolock) --简单生产领料单";
    //        sql += "\r\n 	inner join T_SP_PICKMTRLDATA j with(nolock) on i.FID=j.FID";
    //        sql += "\r\n 	WHERE FDOCUMENTSTATUS='C'";

    //        sql += "\r\n 	union all";
    //        sql += "\r\n 	select i.FAPPROVEDATE,i.FSTOCKORGID,j.FMATERIALID,j.FSTOCKID,j.FSTOCKLOCID,j.FLOT,";
    //        sql += "\r\n 	j.FBASEUNITID,-1*isnull(j.FBASEREALQTY,0),j.FUNITID,-1*isnull(j.FREALQTY,0)";
    //        sql += "\r\n 	from T_PRD_RESTOCK i with(nolock) --生产退库单";
    //        sql += "\r\n 	inner join T_PRD_RESTOCKENTRY j with(nolock) on i.FID=j.FID";
    //        sql += "\r\n 	WHERE FDOCUMENTSTATUS='C'";

    //        sql += "\r\n 	union all";
    //        sql += "\r\n 	select i.FAPPROVEDATE,i.FSTOCKORGID,j.FMATERIALID,j.FSTOCKID,j.FSTOCKLOCID,j.FLOT,";
    //        sql += "\r\n 	j.FBASEUNITID,-1*isnull(j.FBASEOUTQTY,0),j.FUNITID,-1*isnull(j.FOUTQTY,0)";
    //        sql += "\r\n 	from T_SP_OUTSTOCK i with(nolock) --简单生产退库单";
    //        sql += "\r\n 	inner join T_SP_OUTSTOCKENTRY j with(nolock) on i.FID=j.FID";
    //        sql += "\r\n 	WHERE FDOCUMENTSTATUS='C'";

    //        sql += "\r\n 	union all";
    //        sql += "\r\n 	select i.FAPPROVEDATE,i.FSTOCKORGID,j.FMATERIALID,j.FSTOCKID,j.FSTOCKLOCID,j.FLOT,";
    //        sql += "\r\n 	j2.FBASEUNITID,-1*isnull(j2.FBASEACTUALQTY,0),j2.FUNITID,-1*isnull(j2.FACTUALQTY,0)";
    //        sql += "\r\n 	from T_PRD_FEEDMTRL i with(nolock) --生产补料单";
    //        sql += "\r\n 	inner join T_PRD_FEEDMTRLDATA j with(nolock) on i.FID=j.FID";
    //        sql += "\r\n 	inner join T_PRD_FEEDMTRLDATA_Q j2 with(nolock) on j.FID=j2.FID and j.FENTRYID=j2.FENTRYID";
    //        sql += "\r\n 	WHERE FDOCUMENTSTATUS='C'";

    //        sql += "\r\n 	union all";
    //        sql += "\r\n 	select i.FAPPROVEDATE,i.FSTOCKORGID,j.FMATERIALID,j.FSTOCKID,j.FSTOCKLOCID,j.FLOT,";
    //        sql += "\r\n 	j.FBASEUNITID,-1*isnull(j.FBASEACTUALQTY,0),j.FUNITID,-1*isnull(j.FACTUALQTY,0)";
    //        sql += "\r\n 	from T_SUB_PICKMTRL i with(nolock) --委外领料单";
    //        sql += "\r\n 	inner join T_SUB_PICKMTRLDATA j with(nolock) on i.FID=j.FID";
    //        sql += "\r\n 	WHERE FDOCUMENTSTATUS='C'";

    //        sql += "\r\n 	union all";
    //        sql += "\r\n 	select i.FAPPROVEDATE,i.FSTOCKORGID,j.FMATERIALID,j.FSTOCKID,j.FSTOCKLOCID,j.FLOT,";
    //        sql += "\r\n 	j2.FBASEUNITID,-1*isnull(j2.FBASEACTUALQTY,0),j2.FUNITID,-1*isnull(j2.FACTUALQTY,0)";
    //        sql += "\r\n 	from T_SUB_FEEDMTRL i with(nolock) --委外补料单";
    //        sql += "\r\n 	inner join T_SUB_FEEDMTRLENTRY j with(nolock) on i.FID=j.FID";
    //        sql += "\r\n 	inner join T_SUB_FEEDMTRLENTRY_Q j2 with(nolock) on j.FID=j2.FID and j.FENTRYID=j2.FENTRYID";
    //        sql += "\r\n 	WHERE FDOCUMENTSTATUS='C'";

    //        sql += "\r\n 	union all";
    //        sql += "\r\n 	select i.FAPPROVEDATE,i.FSTOCKORGID,j.FMATERIALID,j.FSTOCKID,j.FSTOCKLOCID,j.FLOT,";
    //        sql += "\r\n 	j.FBASEUNITID,-1*isnull(j.FBASEUNITQTY,0),j.FUNITID,-1*isnull(j.FCONSUMEQTY,0)";
    //        sql += "\r\n 	from T_SUB_EXCONSUME i with(nolock) --委外超耗单";
    //        sql += "\r\n 	inner join T_SUB_EXCONSUMEENTRY j with(nolock) on i.FID=j.FID";
    //        sql += "\r\n 	WHERE FDOCUMENTSTATUS='C'";

    //        sql += "\r\n 	union all";
    //        sql += "\r\n 	select i.FAPPROVEDATE,i.FSTOCKORGID,j.FMATERIALID,j.FSTOCKID,j.FSTOCKLOCID,j.FLOT,";
    //        sql += "\r\n 	j.FBASEUNITID,-1*isnull(j.FBASEUNITQTY,0),j.FUNITID,-1*isnull(j.FRMREALQTY,0)";
    //        sql += "\r\n 	from T_PUR_MRB i with(nolock) --采购退料单";
    //        sql += "\r\n 	inner join T_PUR_MRBENTRY j with(nolock) on i.FID=j.FID";
    //        sql += "\r\n 	WHERE FDOCUMENTSTATUS='C'";

    //        sql += "\r\n 	union all";
    //        sql += "\r\n 	select i.FAPPROVEDATE,i.FSTOCKORGID,j.FMATERIALID,j.FSTOCKID,j.FSTOCKLOCID,j.FLOT,";
    //        sql += "\r\n 	j.FBASEUNITID,-1*isnull(j.FBASELOSSQTY,0),j.FUNITID,-1*isnull(j.FLOSSQTY,0)";
    //        sql += "\r\n 	from T_STK_STKCOUNTLOSS i with(nolock) --盘亏单";
    //        sql += "\r\n 	inner join T_STK_STKCOUNTLOSSENTRY j with(nolock) on i.FID=j.FID";
    //        sql += "\r\n 	WHERE FDOCUMENTSTATUS='C'";

    //        sql += "\r\n 	union all";
    //        sql += "\r\n 	select i.FAPPROVEDATE,i.FSTOCKORGID,j.FMATERIALID,j.FSTOCKID,j.FSTOCKLOCID,j.FLOT,";
    //        sql += "\r\n 	j.FBASEUNITID,-1*isnull(j.FBASEQTY,0),j.FUNITID,-1*isnull(j.FQTY,0)";
    //        sql += "\r\n 	from T_STK_MISDELIVERY i with(nolock) --其他出库单";
    //        sql += "\r\n 	inner join T_STK_MISDELIVERYENTRY j with(nolock) on i.FID=j.FID";
    //        sql += "\r\n 	WHERE FDOCUMENTSTATUS='C'";

    //        sql += "\r\n 	union all";
    //        sql += "\r\n 	select i.FAPPROVEDATE,i.FSTOCKORGID,j.FMATERIALID,j.FSTOCKID,j.FSTOCKLOCID,j.FLOT,";
    //        sql += "\r\n 	j.FBASEUNITID,-1*isnull(j.FBASEREALQTY,0),j.FUNITID,-1*isnull(j.FREALQTY,0)";
    //        sql += "\r\n 	from T_REM_OUTSTOCK i with(nolock) --生产线产品退库单";
    //        sql += "\r\n 	inner join T_REM_OUTSTOCKENTRY j with(nolock) on i.FID=j.FID";
    //        sql += "\r\n 	WHERE FDOCUMENTSTATUS='C'";

    //        sql += "\r\n 	union all";
    //        sql += "\r\n 	select i.FAPPROVEDATE,i.FSTOCKORGID,j.FMATERIALID,j.FSTOCKID,j.FSTOCKLOCID,j.FLOT,";
    //        sql += "\r\n 	j.FBASEUNITID,-1*isnull(j.FBASEQTY,0),j.FUNITID,-1*isnull(j.FQTY,0)";
    //        sql += "\r\n 	from T_STK_OEMINSTOCKRTN i with(nolock) --受托加工材料退料单";
    //        sql += "\r\n 	inner join T_STK_OEMINSTOCKRTNENTRY j with(nolock) on i.FID=j.FID";
    //        sql += "\r\n 	WHERE FDOCUMENTSTATUS='C'";

    //        sql += "\r\n 	union all";
    //        sql += "\r\n 	select i.FAPPROVEDATE,i.FSTOCKORGID,j.FMATERIALID,j.FSTOCKID,j.FSTOCKLOCID,j.FLOT,";
    //        sql += "\r\n 	j.FBASEUNITID,-1*isnull(j.FBASEACTUALQTY,0),j.FUNITID,-1*isnull(j.FACTUALQTY,0)";
    //        sql += "\r\n 	from T_REM_PICKMTRL i with(nolock) --生产线领料单";
    //        sql += "\r\n 	inner join T_REM_PICKMTRLDATA j with(nolock) on i.FID=j.FID";
    //        sql += "\r\n 	WHERE FDOCUMENTSTATUS='C'";

    //        sql += "\r\n 	----调拨";
    //        sql += "\r\n 	--union all";
    //        sql += "\r\n 	--select i.FAPPROVEDATE,i.FSTOCKORGID,j.FMATERIALID,j.FDESTSTOCKID,j.FDESTSTOCKLOCID,j.FLOT,";
    //        sql += "\r\n 	--j.FBASEUNITID,isnull(j.FBASEQTY,0),j.FUNITID,isnull(j.FQTY,0)";
    //        sql += "\r\n 	--from T_STK_STKTRANSFERIN i with(nolock) --直接调拨单-调入";
    //        sql += "\r\n 	--inner join T_STK_STKTRANSFERINENTRY j with(nolock) on i.FID=j.FID";
    //        sql += "\r\n 	--WHERE FDOCUMENTSTATUS='C' and FOBJECTTYPEID='STK_TransferDirect'";




    //        sql += "\r\n 	--union all";
    //        sql += "\r\n 	--select i.FAPPROVEDATE,i.FSTOCKOUTORGID,j.FMATERIALID,j.FSRCSTOCKID,j.FSRCSTOCKLOCID,j.FLOT,";
    //        sql += "\r\n 	--j.FBASEUNITID,-1*isnull(j.FBASEQTY,0),j.FUNITID,-1*isnull(j.FQTY,0)";
    //        sql += "\r\n 	--from T_STK_STKTRANSFERIN i with(nolock) --直接调拨单-调出";
    //        sql += "\r\n 	--inner join T_STK_STKTRANSFERINENTRY j with(nolock) on i.FID=j.FID";
    //        sql += "\r\n 	--WHERE FDOCUMENTSTATUS='C' and FOBJECTTYPEID='STK_TransferDirect'";

    //        sql += "\r\n 	union all";
    //        sql += "\r\n 	select i.FAPPROVEDATE,i.FSTOCKORGID,j.FMATERIALID,j.FDESTSTOCKID,j.FDESTSTOCKLOCID,j.FLOT,";
    //        sql += "\r\n 	j.FBASEUNITID,isnull(j.FBASEQTY,0),j.FUNITID,isnull(j.FQTY,0)";
    //        sql += "\r\n 	from T_STK_STKTRANSFERIN i with(nolock) --分步式调入单-调入";
    //        sql += "\r\n 	inner join T_STK_STKTRANSFERINENTRY j with(nolock) on i.FID=j.FID";
    //        sql += "\r\n 	WHERE FDOCUMENTSTATUS='C' and FOBJECTTYPEID='STK_TRANSFERIN' ";

    //        sql += "\r\n 	union all";
    //        sql += "\r\n 	select i.FAPPROVEDATE,i.FSTOCKOUTORGID,j.FMATERIALID,j.FSRCSTOCKID,j.FSRCSTOCKLOCID,j.FLOT,";
    //        sql += "\r\n 	j.FBASEUNITID,-1*isnull(j.FBASEQTY,0),j.FUNITID,-1*isnull(j.FQTY,0)";
    //        sql += "\r\n 	from T_STK_STKTRANSFERIN i with(nolock) --分步式调入单-调出";
    //        sql += "\r\n 	inner join T_STK_STKTRANSFERINENTRY j with(nolock) on i.FID=j.FID";
    //        sql += "\r\n 	WHERE FDOCUMENTSTATUS='C' and FOBJECTTYPEID='STK_TRANSFERIN' ";

    //        sql += "\r\n 	union all";
    //        sql += "\r\n 	select i.FAPPROVEDATE,i.FSTOCKINORGID,j.FMATERIALID,j.FDESTSTOCKID,j.FDESTSTOCKLOCID,j.FLOT,";
    //        sql += "\r\n 	j.FBASEUNITID,isnull(j.FBASEQTY,0),j.FUNITID,isnull(j.FQTY,0)";
    //        sql += "\r\n 	from T_STK_STKTRANSFEROUT i with(nolock) --分步式调出单-调入";
    //        sql += "\r\n 	inner join T_STK_STKTRANSFEROUTENTRY j with(nolock) on i.FID=j.FID";
    //        sql += "\r\n 	WHERE FDOCUMENTSTATUS='C'  and FOBJECTTYPEID='STK_TRANSFERIN' ";

    //        sql += "\r\n 	union all";
    //        sql += "\r\n 	select i.FAPPROVEDATE,i.FSTOCKORGID,j.FMATERIALID,j.FSRCSTOCKID,j.FSRCSTOCKLOCID,j.FLOT,";
    //        sql += "\r\n 	j.FBASEUNITID,-1*isnull(j.FBASEQTY,0),j.FUNITID,-1*isnull(j.FQTY,0)";
    //        sql += "\r\n 	from T_STK_STKTRANSFEROUT i with(nolock) --分步式调出单-调出";
    //        sql += "\r\n 	inner join T_STK_STKTRANSFEROUTENTRY j with(nolock) on i.FID=j.FID";
    //        sql += "\r\n 	WHERE FDOCUMENTSTATUS='C' and FOBJECTTYPEID='STK_TRANSFERIN' ";

    //        sql += "\r\n 	union all";
    //        sql += "\r\n 	select i.FAPPROVEDATE,i.FSTOCKORGID,j.FMATERIALID,j.FDESTSTOCKID,j.FDESTSTOCKLOCID,j.FLOT,";
    //        sql += "\r\n 	j.FBASEUNITID,isnull(j.FBASEQTY,0),j.FUNITID,isnull(j.FQTY,0)";
    //        sql += "\r\n 	from T_REM_STKTRANSFERIN i with(nolock) --生产线仓库调拨单-调入";
    //        sql += "\r\n 	inner join T_REM_STKTRANSFERINENTRY j with(nolock) on i.FID=j.FID";
    //        sql += "\r\n 	WHERE FDOCUMENTSTATUS='C'";

    //        sql += "\r\n 	union all";
    //        sql += "\r\n 	select i.FAPPROVEDATE,i.FSTOCKOUTORGID,j.FMATERIALID,j.FSRCSTOCKID,j.FSRCSTOCKLOCID,j.FLOT,";
    //        sql += "\r\n 	j.FBASEUNITID,-1*isnull(j.FBASEQTY,0),j.FUNITID,-1*isnull(j.FQTY,0)";
    //        sql += "\r\n 	from T_REM_STKTRANSFERIN i with(nolock) --生产线仓库调拨单-调出";
    //        sql += "\r\n 	inner join T_REM_STKTRANSFERINENTRY j with(nolock) on i.FID=j.FID";
    //        sql += "\r\n 	WHERE FDOCUMENTSTATUS='C'";
    //        sql += "\r\n ) i";
    //        sql += "\r\n inner join ";
    //        sql += "\r\n 		(";
    //        sql += "\r\n 			select i.FMATERIALID,i.FNUMBER,j.FNAME from T_BD_MATERIAL i with(nolock)--物料";
    //        sql += "\r\n 			inner join T_BD_MATERIAL_L j with(nolock) on i.FMATERIALID=j.FMATERIALID";
    //        sql += "\r\n 			where j.FLOCALEID=2052 ";
    //        sql += "\r\n 			and i.FMATERIALID in (select FMATERIALID from t_BD_MaterialBase where FISINVENTORY=1)";
    //        sql += "\r\n 		) FMAT on i.FMATERIALID=FMAT.FMATERIALID";


    //        sql += "\r\n left join ";
    //        sql += "\r\n 		(";
    //        sql += "\r\n 			select i.FSTOCKID,i.FNUMBER,j.FNAME from T_BD_STOCK i with(nolock)--仓库";
    //        sql += "\r\n 			inner join T_BD_STOCK_L j with(nolock) on i.FSTOCKID=j.FSTOCKID";
    //        sql += "\r\n 			where j.FLOCALEID=2052 ";
    //        sql += "\r\n 		) FSTO on i.FSTOCKID=FSTO.FSTOCKID";
    //        sql += "\r\n left join ";
    //        sql += "\r\n 		(";
    //        sql += "\r\n 			select i.FORGID,i.FNUMBER,j.FNAME from T_ORG_ORGANIZATIONS i with(nolock)--组织";
    //        sql += "\r\n 			inner join T_ORG_ORGANIZATIONS_L j with(nolock) on i.FORGID=j.FORGID";
    //        sql += "\r\n 			where j.FLOCALEID=2052 ";
    //        sql += "\r\n 		) FORG on i.FSTOCKORGID=FORG.FORGID";
    //        sql += "\r\n left join ";
    //        sql += "\r\n 		(";
    //        sql += "\r\n 			select i.FUNITID,i.FNUMBER,j.FNAME from T_BD_UNIT i with(nolock)--基本单位";
    //        sql += "\r\n 			inner join T_BD_UNIT_L j with(nolock) on i.FUNITID=j.FUNITID";
    //        sql += "\r\n 			where j.FLOCALEID=2052 ";
    //        sql += "\r\n 		) FBASEUNI on i.FBASEUNITID=FBASEUNI.FUNITID";

    //        sql += "\r\n left join ";
    //        sql += "\r\n 		(";
    //        sql += "\r\n 			select i.FUNITID,i.FNUMBER,j.FNAME from T_BD_UNIT i with(nolock)--单位";
    //        sql += "\r\n 			inner join T_BD_UNIT_L j with(nolock) on i.FUNITID=j.FUNITID";
    //        sql += "\r\n 			where j.FLOCALEID=2052 ";
    //        sql += "\r\n 		) FUNI on i.FUNITID=FUNI.FUNITID";
    //        return sql;
    //    }
    //}
    public class ROOT
    {
        public string FormId { get; set; }
        public string FieldKeys { get; set; }
        public string FilterString { get; set; }
        public string GroupString { get; set; }
        public string OrderString { get; set; }
        public int TopRowCount { get; set; }

    }
    public class RETURNROOT
    {
        public bool Success { get; set; }
        public DataTable DataTable { get; set; }
        public List<string> Exception { get; set; }
    }
}

